	<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/1.3.4/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/wu.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/icon.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	$(function(){
		$('#tt').tree({   
    		url:'${pageContext.request.contextPath}/dept?op=dtree',
    		onClick: function(node){
    			$("iframe").attr("src","${pageContext.request.contextPath}/dept?op=getinfo&id="+node.id);
    		},
    		onContextMenu: function(e, node){
				e.preventDefault();
				// 选择节点
				$('#tt').tree('select', node.target);
				// 显示上下文菜单
				$('#mm').menu('show', {
					left: e.pageX,
					top: e.pageY
				});
			},

    		
		});

	});
		//添加方法没写完
		function add(){
			var node = $('#tt').tree('getSelected');
			var isroot = 0;
			$("iframe").attr("src","${pageContext.request.contextPath}/dept?op=toadd&id="+node.id+"&isroot="+isroot+"&pdeptname="+node.text);
		}
		function addroot(){
			$("iframe").attr("src","${pageContext.request.contextPath}/dept?op=toadd&isroot="+1);
		}
		//修改 直接转跳地址
		function change(){
			var node = $('#tt').tree('getSelected');
			$("iframe").attr("src","${pageContext.request.contextPath}/dept?op=getinfo&id="+node.id);
		}
		//删除
		function remove(){
			var node = $('#tt').tree('getSelected');
			if(confirm("确认要删除吗？")){
				$("iframe").attr("src","${pageContext.request.contextPath}/dept?op=dodelete&id="+node.id);
			}
		}
		function reload(){
			$("#tt").tree("reload");
		}
</script>
  </head>
  
<body id="cc" class="easyui-layout" data-options="fit:true" style="">  
    <div data-options="region:'west',title:'',split:true" style="width:200px;">
		<ul id="tt"></ul>
		<input type="button" value="+添加机构" style="margin: 10px 0px 0px 40px" onclick="addroot()">
		<br>
		<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(可以使用右键进行操作)</span>
    </div>  
    <div data-options="region:'center',title:''" style="padding:0px;">
    	<iframe src="" scrolling="auto" width='100%' height='100%' frameborder='0'></iframe>
    </div> 
    <!-- 菜单div -->
    <div id="mm" class="easyui-menu" style="width:120px;">
		<div onclick="add()" data-options="iconCls:'icon-add'">添加</div>
		<div onclick="change()" data-options="iconCls:'icon-edit'">修改</div>
		<div class="menu-sep"></div>  
		<div onclick="remove()" data-options="iconCls:'icon-remove'">删除</div>
	</div>
     
</body> 
</html>

